package com.woniu.mapper;

import com.woniu.entity.OrderItems;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author 11370
* @description 针对表【order_items】的数据库操作Mapper
* @createDate 2025-06-24 18:52:16
* @Entity com.woniu.entity.OrderItems
*/
public interface OrderItemsMapper {

    @Insert("insert into order_items(order_id,product_id,quantity,price,created_at,merchant_id,status) values (#{order_id},#{product_id},#{quantity},#{price},#{created_at},#{merchant_id},#{status})")
    public void insertOrderItem(OrderItems orderItems);

    @Select("select * from order_items where order_id=#{order_id}")
    public List<OrderItems> getOrderItemsByOrderId(Integer order_id);

    @Delete("delete from order_items where order_id=#{order_id}")
    public void deleteOrderItemsByOrderId(Integer order_id);

    @Select("select * from order_items where merchant_id=#{merchant_id}")
    public List<OrderItems> getOrderItemsByMid(Integer merchant_id);

    @Update("update order_items set status=#{status} where merchant_id=#{merchant_id}")
    public void updateOrderItemsStatus(@Param("merchant_id") Integer merchant_id, @Param("status") int status);

    @Update("update order_items set status=#{status} where order_id=#{order_id}")
    public void updateOrderItemsByOrderId(@Param("order_id")Integer order_id,@Param("status")int status);

    @Select("select * from order_items where merchant_id=#{merchant_id} and status=#{status}")
    public List<OrderItems> getOrderItemsByStatus(@Param("merchant_id") Integer merchant_id,@Param("status")Integer status);

    @Delete("delete from order_items where merchant_id=#{merchant_id} and status=#{status}")
    public void deleteByMid(@Param("merchant_id") Integer merchant_id,@Param("status")Integer status);

    @Select("select * from order_items where merchant_id=#{merchant_id} and product_id=#{pid}")
    public List<OrderItems> getOrderItemsByPid(@Param("merchant_id") Integer merchant_id,@Param("pid")Integer pid);

    @Update("update order_items set status=#{status} where order_item_id=#{order_item_id}")
    public void updateOrderItemsByOrderItemId(@Param("order_item_id")Integer order_item_id,@Param("status")int status);

    @Select("select * from order_items where status=#{status}")
    public List<OrderItems> selectOrderItemsByStatus(Integer status);

    @Select("select * from order_items where product_id=#{product_id} and merchant_id=#{merchant_id}")
    public List<OrderItems> getOrderItemsIf(@Param("product_id") Integer product_id,@Param("merchant_id")Integer merchant_id);

    @Select("select * from order_items where product_id=#{pid}")
    public List<OrderItems> selectOrderItemsByPid(Integer pid);
}




